package com.kintreda.ieco_server.bean.account;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.kintreda.ieco_server.bean.system.BaseVo;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 角色信息表
 * @author HuangZhongYao
 *
 */
@Entity
@Table(name = "common_role")
public class Role extends BaseVo {
	
	private static final long serialVersionUID = 1L;

	private String nameEn; // 角色名称 code 
	private String nameZh; // 角色名称
	private String category;//角色所属类型：1admin，2 机构用户 3平台用户
	private String flatType;//单位类型


	@ManyToMany(cascade = CascadeType.MERGE, mappedBy = "roles", fetch = FetchType.LAZY)
	@JsonIgnore
	private Set<User> users; // 用户列表

	@ManyToMany(cascade = CascadeType.PERSIST,fetch = FetchType.EAGER)
	@JoinTable(name = "common_role_menu", joinColumns = { @JoinColumn(name = "roleId",referencedColumnName = "id")}, inverseJoinColumns = { @JoinColumn(name = "menuId",referencedColumnName = "id")})
	@JsonIgnore
	private Set<Menu> menus; // 菜单列表
	

	public String getNameEn() {
		return nameEn;
	}

	public void setNameEn(String nameEn) {
		this.nameEn = nameEn;
	}

	public String getNameZh() {
		return nameZh;
	}

	public void setNameZh(String nameZh) {
		this.nameZh = nameZh;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getFlatType() {
		return flatType;
	}

	public void setFlatType(String flatType) {
		this.flatType = flatType;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	public Set<Menu> getMenus() {
		return menus;
	}

	public void setMenus(Set<Menu> menus) {
		this.menus = menus;
	}
}
